package com.xpd.spring.demo;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.*;

import java.util.ArrayList;
import java.util.List;

@Configuration
@ComponentScan("com.xpd.spring.demo")
public class AnnoConfig {
    @Bean("person")     //相当于bean标签
    public Person person(){
        return new Person();
    }
    @Bean("aaaa")

    public Person aaaa(){
        return new Person(18,"李四");
    }
    @Bean("person1")     //相当于bean标签
    @Primary
    public Person person1(){
        return Person.staticcreate();
    }
    @Bean(initMethod = "init",destroyMethod = "destory")     //相当于bean标签
    public Person person2(@Autowired @Qualifier("aaaa") Person aaaa){
        return aaaa.create();
    }
    @Bean     //相当于bean标签
    @Scope("prototype")
    @Lazy
    public Person person3(@Autowired @Qualifier("person1") Person person1){
      Person person=new Person();
      person.setName("武松");
      person.setAge(30);
      person.setGender('男');
        List<String> list=new ArrayList<>();
        list.add("打篮球");
        list.add("rap");
      person.setLike(list);
      person.mother=new Person();
      person.mother.setName("武松他妈");
      person.father=person1;
      return person;
    }

}
